export default {
  data() {
    return {
      detailTitle: '',
      detailName: '',
      detailProps: {},
    };
  },

  provide() {
    return {
      setDetailHeader: this.setDetailHeader,
      closeDetail: this.closeDetail,
    };
  },

  computed: {
    detailVisible: {
      get() {
        return !_.isEmpty(this.detailName) || !_.isEmpty(this.detailProps);
      },
      set(current) {
        if (!current) {
          this.detailProps = {};
          this.detailName = '';
        }
      }
    }
  },

  methods: {
    setDetailHeader(dialogTitle) {
      this.detailTitle = dialogTitle;
    },

    openDetail({props = {}, detailName}) {
      this.detailProps = props;
      this.detailName = detailName;
    },
    closeDetail() {
      this.detailVisible = false;
    }
  }

};
